var express = require('express');
var router = express.Router();
const multiparty=require("multiparty");

//添加新幻灯片信息
const {admsg2,getad2,delet2,findone2,cgone2}=require('../server/adsServer')
//图片上传
router.post('/AddAd', async function (req, res, next){
     const form =new multiparty.Form();
    form.encoding="utf-8";
    form.uploadDir="./public/files";
    form.parse(req,function(err,fileds,files){    
        res.send(files)
     })
   
})
//添加详细幻灯片信息
router.post('/admsg',async function(req,res){
   const addata=req.body;
   
   const data=await admsg2(addata);
   res.send(data);
})
//获取幻灯片信息
router.get('/getad',async function(req,res){
     const alldata=req.query;
      console.log(alldata);
     const data=await getad2(alldata);
     res.send(data)
})
//删除幻灯片信息
router.get('/delet',async function(req,res){
     const deletdata=req.query
     const data=await delet2(deletdata);
     res.send(data)
})
//修改信息---查找信息
router.get('/getone',async function(req,res){
     const getdata=req.query
     const data=await findone2(getdata);
     res.send(data)
})
//修改信息
router.post('/cgnow',async function(req,res){
     const cgdata=req.body;
     //console.log(cgdata);
     
     const data=await cgone2(cgdata);
     res.send(data);
  })

module.exports = router;